Skip to content

BE-429: HashQL: Add island dependency graph with data requirement resolution#8501

Open
indietyp wants to merge 10 commits intobm/be-428-hashql-simplify-traversal-tracking-to-path-recordingfrom
bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland
Open

BE-429: HashQL: Add island dependency graph with data requirement resolution#8501
indietyp wants to merge 10 commits intobm/be-428-hashql-simplify-traversal-tracking-to-path-recordingfrom
bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland

Conversation

@indietyp
Copy link
Copy Markdown
Member

@indietyp indietyp commented Mar 3, 2026

🌟 What is the purpose of this PR?

This PR implements the island dependency graph construction and scheduling system for the HashQL MIR execution engine. It builds a directed graph over computation islands, resolves data requirements between islands, and computes a topological schedule with parallelism levels for execution.

🔗 Related links

  • Related to the island placement and execution planning work

🔍 What does this change?

  • Adds first_set() method to FiniteBitSet - Returns the first set bit using trailing_zeros(), with comprehensive test coverage for empty sets, single bits, multiple bits, and wide integral types
  • Enhances IdVec with new utility methods - Adds from_raw(), from_domain_derive(), extend_from_slice(), append(), into_iter_enumerated(), and copy_within() methods with detailed documentation and examples
  • Implements island dependency graph (IslandGraph) - Creates a directed graph over IslandNodes connected by three edge types: ControlFlow (execution ordering), DataFlow (data dependencies), and Inherits (path inheritance between same-target dominators)
  • Adds data requirement resolution - Automatically inserts synthetic data islands when traversal paths cannot be satisfied by upstream providers, using dominator analysis to find optimal providers
  • Implements island scheduling (IslandSchedule) - Computes topological ordering with parallelism levels using Kahn's algorithm, allowing islands at the same level to execute concurrently
  • Adds comprehensive test suites - Tests cover single islands, data edges between predecessors, fetch island insertion, diamond CFG patterns, inheritance edges, data island reuse, and scheduling correctness
  • Enables option_into_flat_iter feature - Adds the unstable feature flag for iterator functionality

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • Unit tests for FiniteBitSet::first_set() covering empty sets, single/multiple bits, edge cases
  • Integration tests for island graph construction with various CFG patterns
  • Tests for data requirement resolution including fetch island insertion and reuse
  • Schedule computation tests verifying topological ordering and parallelism levels
  • Tests for edge deduplication and dominator-based inheritance

❓ How to test this?

  1. Run the test suite with cargo test
  2. Check that island graph construction correctly identifies dependencies
  3. Verify that data islands are inserted when traversal paths cannot be satisfied
  4. Confirm that scheduling produces valid topological ordering with correct parallelism levels

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Apr 29, 2026 1:45pm
petrinaut Ready Ready Preview Apr 29, 2026 1:45pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview Apr 29, 2026 1:45pm
hashdotdesign-tokens Ignored Ignored Preview Apr 29, 2026 1:45pm

@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 3, 2026

PR Summary

Medium Risk
Adds new core execution-planning logic (dependency resolution, synthetic data nodes, and scheduling), which could change runtime ordering and data availability if edge cases are missed, though it is well-covered by targeted tests.

Overview
Adds a new IslandGraph execution-planning layer that turns placed islands into a dependency DAG with explicit ControlFlow, DataFlow, and Inherits edges, then resolves per-island traversal-path requirements via dominator analysis (including inserting/reusing synthetic data islands when no upstream provider exists and deduping redundant edges).

Introduces a topological scheduler (IslandSchedule) that assigns parallelism levels (Kahn-style) so independent islands can run concurrently, and re-exports the new graph/schedule types from pass::execution.

Supporting utilities were added in hashql_core (FiniteBitSet::first_set, IdVec::copy_within/into_iter_enumerated and related helpers) plus minor traversal-bitset APIs/docs, with comprehensive new tests covering graph construction, requirement resolution, edge dedup, and scheduling semantics.

Reviewed by Cursor Bugbot for commit a4534ce. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member Author

indietyp commented Mar 3, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Mar 3, 2026

🤖 Augment PR Summary

Summary: Adds an island dependency graph and scheduler to the HashQL MIR execution engine, including automatic data requirement resolution across targets.

Changes:

  • Introduces IslandGraph to model ControlFlow, DataFlow, and Inherits dependencies between computation islands
  • Resolves traversal-path data requirements via dominator analysis and inserts synthetic data islands when no upstream provider exists
  • Adds IslandSchedule to compute a levelized topological schedule (parallelism levels) using Kahn’s algorithm
  • Extends core utilities: FiniteBitSet::first_set() and several IdVec helpers (construction, append/extend, enumerated iteration, copy-within)
  • Adds comprehensive test coverage for bitset behavior, island graph construction/resolution scenarios, and schedule level ordering

Technical Notes: Data island selection uses the first set origin target (backend-priority order), and schedule levels are derived from predecessor constraints to enable safe parallel execution.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread libs/@local/hashql/core/src/id/vec.rs
Comment thread libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs
Comment thread libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs Outdated
Comment thread libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 80 untouched benchmarks


Comparing bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland (a4534ce) with bm/be-428-hashql-simplify-traversal-tracking-to-path-recording (1dde8c7)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 95.29086% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.75%. Comparing base (1dde8c7) to head (a4534ce).

Files with missing lines Patch % Lines
.../hashql/mir/src/pass/execution/island/graph/mod.rs 91.60% 19 Missing and 2 partials ⚠️
...ashql/mir/src/pass/execution/island/graph/tests.rs 97.50% 6 Missing and 1 partial ⚠️
...shql/mir/src/pass/execution/island/schedule/mod.rs 88.46% 6 Missing ⚠️
Additional details and impacted files
@@                                        Coverage Diff                                         @@
##           bm/be-428-hashql-simplify-traversal-tracking-to-path-recording    #8501      +/-   ##
==================================================================================================
+ Coverage                                                           62.57%   62.75%   +0.18%     
==================================================================================================
  Files                                                                1322     1326       +4     
  Lines                                                              134824   135546     +722     
  Branches                                                             5509     5527      +18     
==================================================================================================
+ Hits                                                                84366    85064     +698     
- Misses                                                              49547    49568      +21     
- Partials                                                              911      914       +3     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.40% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.52% <ø> (ø)
rust.hashql-ast 87.23% <ø> (ø)
rust.hashql-compiletest 29.63% <ø> (ø)
rust.hashql-core 82.38% <100.00%> (+0.02%) ⬆️
rust.hashql-eval 69.13% <ø> (ø)
rust.hashql-hir 89.06% <ø> (ø)
rust.hashql-mir 92.45% <95.02%> (+0.11%) ⬆️
rust.hashql-syntax-jexpr 94.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$28.0 \mathrm{ms} \pm 186 \mathrm{μs}\left({\color{gray}-0.930 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.57 \mathrm{ms} \pm 19.2 \mathrm{μs}\left({\color{gray}0.368 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.6 \mathrm{ms} \pm 105 \mathrm{μs}\left({\color{gray}-0.168 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$44.3 \mathrm{ms} \pm 360 \mathrm{μs}\left({\color{gray}-0.454 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.1 \mathrm{ms} \pm 152 \mathrm{μs}\left({\color{gray}0.662 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$24.6 \mathrm{ms} \pm 200 \mathrm{μs}\left({\color{gray}-3.739 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$28.7 \mathrm{ms} \pm 166 \mathrm{μs}\left({\color{gray}-1.639 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.86 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}-0.166 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.5 \mathrm{ms} \pm 88.1 \mathrm{μs}\left({\color{gray}-1.454 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.96 \mathrm{ms} \pm 24.6 \mathrm{μs}\left({\color{gray}-1.148 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.14 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{gray}-0.778 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.49 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}-1.361 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.41 \mathrm{ms} \pm 29.3 \mathrm{μs}\left({\color{gray}-0.501 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.81 \mathrm{ms} \pm 20.7 \mathrm{μs}\left({\color{gray}2.37 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.45 \mathrm{ms} \pm 24.4 \mathrm{μs}\left({\color{gray}2.56 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.61 \mathrm{ms} \pm 25.4 \mathrm{μs}\left({\color{gray}-1.729 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.62 \mathrm{ms} \pm 23.5 \mathrm{μs}\left({\color{gray}-0.264 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.24 \mathrm{ms} \pm 21.7 \mathrm{μs}\left({\color{gray}-1.297 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.89 \mathrm{ms} \pm 15.0 \mathrm{μs}\left({\color{gray}0.589 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.84 \mathrm{ms} \pm 16.1 \mathrm{μs}\left({\color{gray}0.440 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.95 \mathrm{ms} \pm 11.7 \mathrm{μs}\left({\color{gray}-0.320 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$3.21 \mathrm{ms} \pm 17.4 \mathrm{μs}\left({\color{gray}-0.191 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.03 \mathrm{ms} \pm 13.7 \mathrm{μs}\left({\color{gray}-0.789 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$3.33 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-0.311 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$3.22 \mathrm{ms} \pm 15.2 \mathrm{μs}\left({\color{gray}-1.351 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.96 \mathrm{ms} \pm 13.6 \mathrm{μs}\left({\color{gray}-1.611 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$3.10 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}-1.277 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.70 \mathrm{ms} \pm 18.7 \mathrm{μs}\left({\color{gray}0.036 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.24 \mathrm{ms} \pm 18.0 \mathrm{μs}\left({\color{gray}-1.522 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.48 \mathrm{ms} \pm 23.3 \mathrm{μs}\left({\color{gray}-0.596 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.60 \mathrm{ms} \pm 24.9 \mathrm{μs}\left({\color{gray}-0.950 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.20 \mathrm{ms} \pm 13.6 \mathrm{μs}\left({\color{gray}-3.209 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.49 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}-1.113 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$43.9 \mathrm{ms} \pm 212 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$79.8 \mathrm{ms} \pm 436 \mathrm{μs}\left({\color{lightgreen}-6.870 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$46.9 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{gray}-2.645 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$49.9 \mathrm{ms} \pm 326 \mathrm{μs}\left({\color{gray}0.891 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$58.5 \mathrm{ms} \pm 343 \mathrm{μs}\left({\color{gray}-0.299 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$46.1 \mathrm{ms} \pm 209 \mathrm{μs}\left({\color{gray}3.10 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$420 \mathrm{ms} \pm 1.07 \mathrm{ms}\left({\color{gray}0.828 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$100 \mathrm{ms} \pm 468 \mathrm{μs}\left({\color{gray}0.462 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$92.1 \mathrm{ms} \pm 406 \mathrm{μs}\left({\color{gray}3.57 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$297 \mathrm{ms} \pm 809 \mathrm{μs}\left({\color{gray}2.16 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$16.9 \mathrm{ms} \pm 117 \mathrm{μs}\left({\color{red}5.83 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$16.3 \mathrm{ms} \pm 80.0 \mathrm{μs}\left({\color{gray}0.142 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$16.7 \mathrm{ms} \pm 80.2 \mathrm{μs}\left({\color{gray}1.95 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$16.6 \mathrm{ms} \pm 86.5 \mathrm{μs}\left({\color{gray}1.72 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$19.4 \mathrm{ms} \pm 118 \mathrm{μs}\left({\color{gray}0.516 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$15.8 \mathrm{ms} \pm 69.9 \mathrm{μs}\left({\color{gray}-1.614 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$16.1 \mathrm{ms} \pm 78.4 \mathrm{μs}\left({\color{gray}0.723 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$16.1 \mathrm{ms} \pm 95.2 \mathrm{μs}\left({\color{gray}1.17 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$16.8 \mathrm{ms} \pm 102 \mathrm{μs}\left({\color{gray}1.66 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$23.9 \mathrm{ms} \pm 150 \mathrm{μs}\left({\color{gray}-0.307 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$31.8 \mathrm{ms} \pm 252 \mathrm{μs}\left({\color{gray}2.41 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$32.5 \mathrm{ms} \pm 328 \mathrm{μs}\left({\color{gray}2.01 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$32.0 \mathrm{ms} \pm 331 \mathrm{μs}\left({\color{gray}0.301 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$32.6 \mathrm{ms} \pm 304 \mathrm{μs}\left({\color{gray}4.00 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$31.2 \mathrm{ms} \pm 314 \mathrm{μs}\left({\color{gray}-0.883 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$32.5 \mathrm{ms} \pm 344 \mathrm{μs}\left({\color{gray}1.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$30.9 \mathrm{ms} \pm 299 \mathrm{μs}\left({\color{gray}-0.340 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$31.2 \mathrm{ms} \pm 313 \mathrm{μs}\left({\color{gray}2.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$32.1 \mathrm{ms} \pm 313 \mathrm{μs}\left({\color{gray}3.18 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.95 \mathrm{ms} \pm 42.2 \mathrm{μs}\left({\color{gray}1.15 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$91.6 \mathrm{ms} \pm 492 \mathrm{μs}\left({\color{gray}1.70 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$145 \mathrm{ms} \pm 577 \mathrm{μs}\left({\color{gray}-0.274 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$98.4 \mathrm{ms} \pm 544 \mathrm{μs}\left({\color{gray}1.00 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$107 \mathrm{ms} \pm 490 \mathrm{μs}\left({\color{gray}0.852 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$116 \mathrm{ms} \pm 511 \mathrm{μs}\left({\color{gray}0.297 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$124 \mathrm{ms} \pm 590 \mathrm{μs}\left({\color{gray}0.642 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$87.8 \mathrm{ms} \pm 395 \mathrm{μs}\left({\color{gray}-1.608 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$117 \mathrm{ms} \pm 491 \mathrm{μs}\left({\color{gray}-0.258 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$95.8 \mathrm{ms} \pm 551 \mathrm{μs}\left({\color{gray}-0.374 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$104 \mathrm{ms} \pm 490 \mathrm{μs}\left({\color{gray}-0.888 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$108 \mathrm{ms} \pm 562 \mathrm{μs}\left({\color{gray}0.058 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$106 \mathrm{ms} \pm 483 \mathrm{μs}\left({\color{gray}-0.833 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$134 \mathrm{ms} \pm 540 \mathrm{μs}\left({\color{gray}-2.870 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$133 \mathrm{ms} \pm 532 \mathrm{μs}\left({\color{gray}-2.434 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$79.9 \mathrm{ms} \pm 3.29 \mathrm{ms}\left({\color{red}21.5 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$578 \mathrm{ms} \pm 872 \mathrm{μs}\left({\color{gray}1.13 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp force-pushed the bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland branch from 74ce977 to b8fe72b Compare March 31, 2026 20:56
@indietyp indietyp force-pushed the bm/be-428-hashql-simplify-traversal-tracking-to-path-recording branch from 2346ece to 5e31131 Compare March 31, 2026 20:56
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 31, 2026

Deployment failed with the following error:

Invalid request: `attribution.gitUser` should NOT have additional property `isBot`.

@github-actions github-actions Bot dismissed TimDiekmann’s stale review March 31, 2026 20:57

Latest approval commit 572197c is not an ancestor of b8fe72b, indicating rewritten history after approval

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for all 3 issues found in the latest run.

  • ✅ Fixed: Cycles silently drop scheduled islands
    • Added a full-node-count assertion in schedule_in so cyclic control-flow now fails loudly instead of returning a partial schedule.
  • ✅ Fixed: Range bound semantics are lost
    • Updated IdVec::copy_within to preserve Bound::{Included,Excluded,Unbounded} when converting typed ID bounds to usize bounds.
  • ✅ Fixed: Requirement resolution assumes acyclic control flow
    • Replaced DFS-postorder-based ordering with Kahn topological ordering plus a cycle assertion in island requirement resolution.

Create PR

Or push these changes by commenting:

@cursor push 27aca44a02
Preview (27aca44a02)
diff --git a/libs/@local/hashql/core/src/id/vec.rs b/libs/@local/hashql/core/src/id/vec.rs
--- a/libs/@local/hashql/core/src/id/vec.rs
+++ b/libs/@local/hashql/core/src/id/vec.rs
@@ -6,7 +6,7 @@
     fmt::{self, Debug},
     hash::{Hash, Hasher},
     marker::PhantomData,
-    ops::{Deref, DerefMut, RangeBounds},
+    ops::{Bound, Deref, DerefMut, RangeBounds},
     slice,
 };
 
@@ -510,8 +510,16 @@
     where
         T: Copy,
     {
-        let start = src.start_bound().copied().map(Id::as_usize);
-        let end = src.end_bound().copied().map(Id::as_usize);
+        let start = match src.start_bound() {
+            Bound::Included(&bound) => Bound::Included(bound.as_usize()),
+            Bound::Excluded(&bound) => Bound::Excluded(bound.as_usize()),
+            Bound::Unbounded => Bound::Unbounded,
+        };
+        let end = match src.end_bound() {
+            Bound::Included(&bound) => Bound::Included(bound.as_usize()),
+            Bound::Excluded(&bound) => Bound::Excluded(bound.as_usize()),
+            Bound::Unbounded => Bound::Unbounded,
+        };
 
         self.raw.copy_within((start, end), dst.as_usize());
     }
@@ -796,3 +804,23 @@
         Self::from_raw(Vec::from_iter_in(iter, alloc))
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::IdVec;
+    use crate::id::{Id as _, newtype};
+
+    newtype!(#[id(crate = crate)] struct TestId(u32 is 0..=32));
+
+    #[test]
+    fn copy_within_preserves_inclusive_end_bound() {
+        let mut vec = IdVec::<TestId, i32>::from_raw(alloc::vec![10, 20, 30]);
+
+        vec.copy_within(
+            TestId::from_usize(1)..=TestId::from_usize(1),
+            TestId::from_usize(0),
+        );
+
+        assert_eq!(vec.as_slice().as_raw(), &[20, 20, 30]);
+    }
+}

diff --git a/libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs b/libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs
--- a/libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs
+++ b/libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs
@@ -20,7 +20,7 @@
 #[cfg(test)]
 pub(crate) mod tests;
 
-use alloc::alloc::Global;
+use alloc::{alloc::Global, collections::VecDeque};
 use core::{
     alloc::Allocator,
     ops::{Index, IndexMut},
@@ -29,11 +29,10 @@
 use hashql_core::{
     debug_panic,
     graph::{
-        DirectedGraph, EdgeId, LinkedGraph, NodeId, Predecessors, Successors, Traverse as _,
+        DirectedGraph, EdgeId, LinkedGraph, NodeId, Predecessors, Successors,
         algorithms::{Dominators, dominators},
         linked::Edge,
     },
-    heap::CollectIn as _,
     id::{
         HasId as _, Id as _,
         bit_vec::{BitMatrix, DenseBitSet},
@@ -243,13 +242,39 @@
     where
         S: Allocator + Clone,
     {
-        let mut topo: Vec<IslandId, _> = self
-            .inner
-            .depth_first_forest_post_order()
-            .map(|node| IslandId::new(node.as_u32()))
-            .collect_in(scratch.clone());
-        topo.reverse();
+        #[expect(clippy::cast_possible_truncation)]
+        let node_count = self.node_count();
+        let mut in_degree = IslandVec::from_elem_in(0_u32, node_count, scratch.clone());
+        for (island_id, _) in self.iter_nodes() {
+            in_degree[island_id] = self.predecessors(island_id).count() as u32;
+        }
 
+        let mut queue: VecDeque<IslandId, _> = VecDeque::new_in(scratch.clone());
+        for (island_id, _) in self.iter_nodes() {
+            if in_degree[island_id] == 0 {
+                queue.push_back(island_id);
+            }
+        }
+
+        let mut topo = Vec::with_capacity_in(node_count, scratch.clone());
+        while let Some(island_id) = queue.pop_front() {
+            topo.push(island_id);
+
+            for successor in self.successors(island_id) {
+                in_degree[successor] -= 1;
+
+                if in_degree[successor] == 0 {
+                    queue.push_back(successor);
+                }
+            }
+        }
+
+        assert_eq!(
+            topo.len(),
+            node_count,
+            "island requirement resolution requires acyclic control flow",
+        );
+
         let start = self.lookup[BasicBlockId::START];
 
         RequirementResolver::new(self, start, scratch).resolve(&topo);
@@ -379,7 +404,7 @@
     }
 
     fn resolve(mut self, topo: &[IslandId]) {
-        // Iterate in reverse for topological order
+        // Iterate in topological order so dominators are processed before dependents.
         for &island_id in topo {
             let island = &self.graph[island_id];
             let IslandKind::Exec(_) = &island.kind else {

diff --git a/libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs b/libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs
--- a/libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs
+++ b/libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs
@@ -122,6 +122,12 @@
             }
         }
 
+        assert_eq!(
+            entries.len(),
+            node_count,
+            "island schedule requires acyclic control flow",
+        );
+
         entries.sort_by_key(|entry| entry.level);
         IslandSchedule { entries }
     }

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread libs/@local/hashql/mir/src/pass/execution/island/schedule/mod.rs
Comment thread libs/@local/hashql/core/src/id/vec.rs
Comment thread libs/@local/hashql/mir/src/pass/execution/island/graph/mod.rs
@indietyp indietyp force-pushed the bm/be-428-hashql-simplify-traversal-tracking-to-path-recording branch from 5e31131 to b32bd45 Compare April 21, 2026 17:06
@indietyp indietyp force-pushed the bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland branch from b8fe72b to 69a8667 Compare April 21, 2026 17:06
@indietyp indietyp force-pushed the bm/be-428-hashql-simplify-traversal-tracking-to-path-recording branch from b32bd45 to 9231d97 Compare April 29, 2026 13:08
@indietyp indietyp force-pushed the bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland branch from 69a8667 to 40ba97b Compare April 29, 2026 13:08
@indietyp indietyp force-pushed the bm/be-429-hashql-per-island-entitypath-requirements-and-fetchisland branch from 40ba97b to a4534ce Compare April 29, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

3 participants